import request from '@/utils/request';

// 获取活动规则列表
export function ruleData() {
  return request({
    url: `/v1/rule/list`,
    method: 'get'
  });
}

// 获取固定规则列表
export function fixedRuleData() {
  return request({
    url: `/v1/fixedRule/list`,
    method: 'get'
  });
}

// 新增固定规则
export function addfixedRule(rule) {
  return request({
    url: `/v1/fixedRule/add`,
    method: 'post',
    data: rule
  });
}

// 删除固定规则
export function delfixedRule(data) {
  return request({
    url: `/v1/fixedRule/del?id=${data.id}&page=${data.page}`,
    method: 'get'
  });
}

// 自定义规则搜索
export function searchData(rule) {
  return request({
    url: `v1/rule/search`,
    method: 'post',
    data: rule
  });
}

// 用户异常处理
export function changeStatus(data) {
  return request({
    url: `/v1/member/changeStatus`,
    method: 'post',
    data
  });
}

// 固定规则用户异常处理
export function fixedRuleSearch(query) {
  return request({
    url: `/v1/fixedRule/search?status=${query.type}&memberId=${query.memberId}&nickName=${query.nickName}&tel=${query.tel}&ruleNameFragment=${query.ruleNameFragment}&beginTime=${query.beginTime}&endTime=${query.endTime}&pageIndex=${query.pageIndex}&pageSize=${query.pageSize}`,
    method: 'get'
  });
}

// 用户异常管理
export function memberSearch(query) {
  return request({
    url: `/v1/member/search?status=${query.type}&&memberId=${query.memberId}&nickName=${query.nickName}&tel=${query.tel}&ruleNameFragment=${query.ruleNameFragment}&beginTime=${query.beginTime}&endTime=${query.endTime}&pageIndex=${query.pageIndex}&pageSize=${query.pageSize}`,
    method: 'get'
  });
}

// 白名单查询
export function getWhiteList(query) {
  return request({
    url: `/v1/whiteList/search?memberId=${query.memberId}&nickName=${query.nickName}&tel=${query.tel}&ruleNameFragment=${query.ruleNameFragment}&beginTime=${query.beginTime}&endTime=${query.endTime}&pageIndex=${query.pageIndex}&pageSize=${query.pageSize}`,
    method: 'get'
  });
}

// 白名单添加
export function addWhite(data) {
  return request({
    url: `/v1/whiteList/add`,
    method: 'post',
    data
  });
}

// 白名单 删除delWhite
export function delWhite(data) {
  return request({
    url: `/v1/whiteList/del`,
    method: 'post',
    data
  });
}

// 判断规则是否是白名单
export function isWhiteRules(data) {
  return request({
    url: `/v1/member/getNeedProtectRules`,
    method: 'post',
    data
  });
}

// 获取会员名单
export function getMemberList(params) {
  return request({
    url: `/v1/member/searchPage`,
    method: 'get',
    params
  });
}

// 修改会员状态
export function changeStatusApi(data) {
  return request({
    url: `/v1/member/changeStatus`,
    method: 'post',
    data
  });
}

// 会员是否存在申请未处理
export function existApplyApi(params) {
  return request({
    url: `/v1/memberrisk/existApply`,
    method: 'get',
    params
  });
}

// 白名单添加
export function addWhiteApi(data) {
  return request({
    url: `/v1/whiteList/add`,
    method: 'post',
    data
  });
}
